package cn.wendellup.bootStrap.web;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import cn.egame.common.exception.ExceptionCommonBase;
import cn.wendellup.bootStrap.service.contract.IUserService;
import cn.wendellup.bootStrap.valueobject.entity.UserInfo;
import cn.wendellup.bootStrap.web.base.service.BaseController;

@Controller
@RequestMapping(value="/user")
public class UserController extends BaseController{
	@Autowired
	private IUserService userService;
	 
	/**
	 * @Description: 分页展现所有用户的列表页 
	 * @Author yuchao
	 * @Create Date  2013-8-10
	 * @Modified by none
	 * @Modified Date
	 */
	@RequestMapping(value = "/listUser")
	public ModelAndView listUser(HttpServletRequest request, HttpServletResponse
			response) throws ExceptionCommonBase{
		List<UserInfo> userList = userService.listUsers();
		Map<String, Object> model = new HashMap<String, Object>();
		model.put("userList", userList);
		ModelAndView mav = new ModelAndView("user/listUser",model);
		return mav;
	}
	
	@RequestMapping(value = "/testJson")
	@ResponseBody
	public Object listUserJson(HttpServletRequest request, HttpServletResponse
			response) throws ExceptionCommonBase{
		List<UserInfo> userList = userService.listUsers();
		return userList;
	}
}
